44 Lecture
CS402
Midterm & Final Term Short Notes
Parsing Techniques
Parsing techniques refer to the methods and algorithms used to analyze a sequence of tokens or symbols according to the rules of a formal grammar. These techniques are used in computer science and programming to convert input data into a structu
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
Which of the following is NOT a parsing technique? a) Top-down parsing b) Bottom-up parsing c) Recursive descent parsing d) Infix parsing Answer: d) Infix parsing Which parsing technique starts at the root of the parse tree and works downwards towards the leaves? a) Top-down parsing b) Bottom-up parsing c) Recursive descent parsing d) LR parsing Answer: a) Top-down parsing Which parsing technique starts at the leaves of the parse tree and works upwards towards the root? a) Top-down parsing b) Bottom-up parsing c) Recursive descent parsing d) SLR parsing Answer: b) Bottom-up parsing Which parsing technique uses a stack to keep track of the symbols in the input and the rules of the grammar? a) Top-down parsing b) Bottom-up parsing c) Recursive descent parsing d) LALR parsing Answer: b) Bottom-up parsing Which parsing technique is most commonly used in compilers and language processing tools? a) Top-down parsing b) Bottom-up parsing c) Recursive descent parsing d) LR parsing Answer: d) LR parsing Which parsing technique can handle left-recursive grammars? a) Top-down parsing b) Bottom-up parsing c) Recursive descent parsing d) Earley parsing Answer: d) Earley parsing Which parsing technique is a type of top-down parsing that uses a predictive parsing table? a) LL parsing b) SLR parsing c) LALR parsing d) LR parsing Answer: a) LL parsing Which parsing technique is a type of bottom-up parsing that uses a canonical LR(1) parser? a) LL parsing b) SLR parsing c) LALR parsing d) CLR parsing Answer: d) CLR parsing Which parsing technique is a type of top-down parsing that uses recursive function calls to build the parse tree? a) LL parsing b) SLR parsing c) Recursive descent parsing d) LR parsing Answer: c) Recursive descent parsing Which parsing technique is capable of handling ambiguous grammars? a) LL parsing b) SLR parsing c) LALR parsing d) GLR parsing Answer: d) GLR parsing
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
- What is parsing and why is it necessary in computer science?
Parsing is the process of analyzing a sequence of tokens or symbols according to the rules of a formal grammar. It is necessary in computer science because it allows a computer program to convert input data into a structured representation that can be processed.
What is the difference between top-down and bottom-up parsing?
Top-down parsing starts at the root of the parse tree and works downwards towards the leaves, while bottom-up parsing starts at the leaves of the parse tree and works upwards towards the root.
What is a predictive parsing table?
A predictive parsing table is a table that is used in LL parsing to determine which production rule to apply next based on the current input symbol and the top of the parsing stack.
What is the difference between LL and LR parsing?
LL parsing is a top-down parsing technique that reads input from left to right and produces a leftmost derivation, while LR parsing is a bottom-up parsing technique that reads input from left to right and produces a rightmost derivation.
What is a shift-reduce parser?
A shift-reduce parser is a bottom-up parser that uses a stack to keep track of the symbols in the input and the rules of the grammar. It works by repeatedly shifting symbols onto the stack and then reducing them according to the rules of the grammar.
What is the difference between SLR and LR(1) parsing?
SLR parsing is a simpler and less powerful variant of LR(1) parsing. It uses a smaller parsing table and can only handle a subset of LR(1) grammars.
What is a parsing tree and how is it constructed?
A parsing tree is a data structure that represents the syntactic structure of a sequence of tokens or symbols. It is constructed by applying the production rules of a formal grammar to the input sequence of symbols.
What is a left-recursive grammar and why is it problematic for some parsing techniques?
A left-recursive grammar is a grammar in which the left-hand side of a production rule can derive a string that starts with the same nonterminal symbol. This can cause problems for some parsing techniques, such as top-down parsing, which can get stuck in an infinite loop.
What is a grammar ambiguity and how is it resolved?
A grammar ambiguity is a situation where a single input can be parsed in multiple ways. It can be resolved by either modifying the grammar to remove the ambiguity or by using a parsing technique that can handle ambiguous grammars, such as GLR parsing.
What is the difference between a regular language and a context-free language, and how does this affect parsing?
A regular language is a language that can be recognized by a finite-state automaton, while a context-free language is a language that can be generated by a context-free grammar. Parsing techniques for regular languages are generally simpler and more efficient than parsing techniques for context-free languages.